# -*- coding: utf-8 -*-
"""
@Time ： 2020/12/2 17:58
@Auth ： Mr. JJ_Cloud
@Company ：testingedu.com.cn
@Function ：查看ip地址和hosts文件
"""

import os

# os.system('chcp 65001')
# os.system("ipconfig")
print(os.popen('ipconfig').read())

import platform as p

# print(os.system())
p1 = p.system()
path = 'C:\Windows\System32\drivers\etc'
os.chdir(path)
file = 'hosts'

def read_hosts():
    with open(file, 'r') as fs:
        data = fs.readlines()
    return data

if __name__ == '__main__':
    if p1 == "Windows":
        datas = read_hosts()
        for data in datas:
            print(data)
